package com.yanqu.road.dataHelper.action.excel;

import com.yanqu.road.dataHelper.gameServer.GameServer;
import com.yanqu.road.dataHelper.manager.ActivityMgr;
import com.yanqu.road.dataHelper.manager.BaseMgr;
import com.yanqu.road.dataHelper.manager.ConfigMgr;
import com.yanqu.road.dataHelper.manager.DataMgr;
import com.yanqu.road.dataHelper.repair.BaseRepair;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.utils.date.DateHelper;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author xx
 * @Date 2020/11/11
 */
public class ChangeTitle extends BaseRepair {

    public ChangeTitle(GameServer gameServer) {
        super(gameServer);
    }

    @Override
    public void repair(long param1, String param2) {

    }

    public void go(){
        if(System.currentTimeMillis() < 1611676800000L){
            String userId = getGameServer().getServerInfo().getServerId() + "0000001";
            changeUserTitle(userId);
        }
    }

    private List<Map<String, String>> changeUserTitle(String userId) {
        List<Map<String, String>> dataList = new ArrayList<>();
        ResultSet rs = null;
        CallableStatement call = null;
        String sql = "UPDATE t_u_user SET titleId = 15 WHERE userId = ?";
        try {
            call = getGameServer().getConnection().prepareCall(sql);
            int i=1;
            call.setString(i++,userId);
            if(call.executeUpdate() > 0){
                getLogger().error(sql + userId);
            }
            System.err.println(userId + "修改成功");
        } catch (SQLException ex) {
            getGameServer().getLogger().error("异常错误", ex);
        } finally {
            getGameServer().closeConnection(call, rs);
        }
        return dataList;
    }
}
